package stu.day19_day24.day20;

public class LeetCode122 {
    public int maxProfit(int[] prices) {

        int len = prices.length;
        int num = 0;


        if(len<=1){
            return 0;
        }else {
            for(int i=1;i<len;i++){
                if(prices[i]>prices[i-1]){
                    num += prices[i]-prices[i-1];
                }
            }
            return num;
        }

    }



}
